/* This file is part of the KDE project
   Copyright (C) 2003 Dominik Seichter <domseichter@web.de>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the Lesser GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#ifndef KIMG_IFF_H
#define KIMG_IFF_H

#include <QtGui/QImageIOPlugin>

struct BMHDChunk {
    unsigned short Width;
    unsigned short Height;
    unsigned short XOrigin;
    unsigned short YOrigin;
    unsigned char Bitplanes;
    unsigned char Mask;
    unsigned char Compression;
    unsigned char Padding;          // unused
    unsigned short Transparency;
    unsigned short Aspect;
    unsigned short PageWidth;
    unsigned short PageHeight;
    enum { SIZE = 4 };
};

enum ViewModeFlags {
    lace = 0x00000004,
    extraHalfbrite = 0x00000080,
    ham = 0x00000800,
    hiRes = 0x00008000
};

class IFFHandler : public QImageIOHandler
{
    quint8 *chunky;
    quint8 *cmap;
    int depth;
    int xpos;
    int ypos;
    BMHDChunk BMHD;
    void feedPlanar(quint8 value);
public:
    IFFHandler();

    bool canRead() const;
    bool read(QImage *image);
    bool write(const QImage &image);

    QByteArray name() const;

    static bool canRead(QIODevice *device);
};

#endif

